package xiecheng;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.Scanner;

public class Main1 {
	 public static void main(String[] args) {
	  	Scanner sc = new Scanner(System.in);
        int numberOfrecords = sc.nextInt();
        int Searchtime = sc.nextInt();
        ArrayList<String> res = new ArrayList<>();
        for(int i=0;i<numberOfrecords;i++) {
         String m = sc.next();
         int line1 = sc.nextInt();
         int line2 = sc.nextInt();
         if (Searchtime>=line1&&Searchtime<=line2) {
        	 res.add(m);
         }
        }
        if (!res.isEmpty()) {
        	Collections.sort(res);
			Iterator<String> it = res.iterator();
			while (it.hasNext()) {
				String s = it.next();
				System.out.println(s);
			}	   
		}else {
			System.out.println("null");
		}
	 }
}
